import 'package:color_dart/HexColor.dart';
import 'package:color_dart/RgbaColor.dart';
import "package:flutter/material.dart";
import 'package:im_flutter_sdk_example/components/a_button/index.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';
import 'package:im_flutter_sdk_example/provider/group_formdate_model.dart';
import 'package:provider/provider.dart';

class AllianceCreate extends StatefulWidget {
  @override
  _AllianceCreateState createState() => _AllianceCreateState();
}

class _AllianceCreateState extends State<AllianceCreate> {
  @override
  Widget build(BuildContext context) {
    GroupFormDataModel _formData = Provider.of<GroupFormDataModel>(context);
    return Scaffold(
      appBar: AppBar(
        title: Text('创建小组'),
        actions: <Widget>[
          GestureDetector(
            onTap: _formData.submit,
            child: Row(children: [
              Container(
                margin: EdgeInsets.only(right: 10),
                padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(2),
                  color: rgba(42, 125, 250, 1),
                ),
                child: Text(
                  '保存',
                  style: TextStyle(
                    color: rgba(255, 255, 255, 1),
                  ),
                ),
              )
            ]),
          )
        ],
      ),
      body: Container(
        color: Colors.white,
        child: Column(
          children: [
            Divider(
              height: 1.0,
              indent: 0.0,
              color: rgba(242, 242, 242, 1),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 20, vertical: 0),
              child: Column(
                children: [
                  ListTile(
                    title: _formData.myGroup.logo == ''
                        ? Text(
                            "小组LOGO",
                            style: TextStyle(
                              color: rgba(34, 34, 34, 1),
                            ),
                          )
                        : Row(
                            children: [
                              Container(
                                width: 83,
                                height: 83,
                                decoration: BoxDecoration(
                                    shape: BoxShape.rectangle,
                                    color: rgba(255, 255, 255, 1),
                                    borderRadius:
                                        BorderRadius.all(Radius.circular(11)),
                                    boxShadow: [
                                      BoxShadow(
                                          color: rgba(0, 0, 0, 0.05),
                                          offset: Offset(0.0, 4.0), //阴影xy轴偏移量
                                          blurRadius: 8, //阴影模糊程度
                                          spreadRadius: 1.0 //阴影扩散程度
                                          )
                                    ]),
                                child: SizedBox(
                                  width: 83,
                                  height: 83,
                                  child: Image.network(
                                    _formData.myGroup.logo,
                                    fit: BoxFit.cover,
                                  ),
                                ),
                              ),
                            ],
                          ),
                    contentPadding:
                        EdgeInsets.symmetric(horizontal: 0, vertical: 21),
                    trailing: SizedBox(
                      width: 100,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          Container(
                            width: 100,
                            height: 32,
                            decoration: BoxDecoration(
                              borderRadius:
                                  BorderRadius.all(Radius.circular(16)),
                              color: rgba(42, 125, 250, 1),
                            ),
                            child: AButton.normal(
                                width: 100,
                                child: Text('上传图片'),
                                borderRadius: BorderRadius.circular(44),
                                color: hex('#fff'),
                                bgColor: rgba(42, 125, 250, 1),
                                borderColor: rgba(136, 175, 213, 1),
                                onPressed: _formData.onImagePress),
                          )
                        ],
                      ),
                    ),
                  ),
                  Divider(
                    height: 1.0,
                    indent: 0.0,
                    color: rgba(242, 242, 242, 1),
                  ),
                  ListTile(
                    onTap: () =>
                        {G.pushNamed('/write_group_name', arguments: 'name')},
                    contentPadding:
                        EdgeInsets.symmetric(horizontal: 0, vertical: 8),
                    title: Text(
                      "小组名称",
                      style: TextStyle(
                        color: rgba(34, 34, 34, 1),
                      ),
                    ),
                    trailing: SizedBox(
                      width: 130,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          Container(
                            width: 100,
                            child: Text(
                              _formData.myGroup.name != null
                                  ? _formData.myGroup.name
                                  : '',
                              style: TextStyle(
                                color: rgba(34, 34, 34, 1),
                              ),
                              textAlign: TextAlign.end,
                              overflow: TextOverflow.ellipsis,
                              maxLines: 1,
                            ),
                          ),
                          Padding(
                            padding: const EdgeInsets.only(left: 10),
                            child: Icon(
                              Icons.arrow_forward_ios_sharp,
                              size: 12,
                              color: rgba(163, 163, 163, 1),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Divider(
                    height: 1.0,
                    indent: 0.0,
                    color: rgba(242, 242, 242, 1),
                  ),
                  ListTile(
                    onTap: () => {
                      G.pushNamed('/write_group_name', arguments: 'summary')
                    },
                    contentPadding:
                        EdgeInsets.symmetric(horizontal: 0, vertical: 8),
                    title: Text(
                      "小组简介",
                      style: TextStyle(
                        color: rgba(34, 34, 34, 1),
                      ),
                    ),
                    trailing: SizedBox(
                      width: 130,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          Container(
                            width: 100,
                            child: Text(
                              _formData.myGroup.summary != null
                                  ? _formData.myGroup.summary
                                  : '',
                              style: TextStyle(
                                color: rgba(34, 34, 34, 1),
                              ),
                              textAlign: TextAlign.end,
                              overflow: TextOverflow.ellipsis,
                              maxLines: 1,
                            ),
                          ),
                          Padding(
                            padding: const EdgeInsets.only(left: 10),
                            child: Icon(
                              Icons.arrow_forward_ios_sharp,
                              size: 12,
                              color: rgba(163, 163, 163, 1),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Divider(
                    height: 1.0,
                    indent: 0.0,
                    color: rgba(242, 242, 242, 1),
                  ),
                  ListTile(
                    onTap: () =>
                        {G.pushNamed('/write_group_name', arguments: 'note')},
                    contentPadding:
                        EdgeInsets.symmetric(horizontal: 0, vertical: 8),
                    title: Text(
                      "小组通知",
                      style: TextStyle(
                        color: rgba(34, 34, 34, 1),
                      ),
                    ),
                    trailing: SizedBox(
                      width: 130,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          Container(
                            width: 100,
                            child: Text(
                              _formData.myGroup.note != null
                                  ? _formData.myGroup.note
                                  : '',
                              style: TextStyle(
                                color: rgba(34, 34, 34, 1),
                              ),
                              textAlign: TextAlign.end,
                              overflow: TextOverflow.ellipsis,
                              maxLines: 1,
                            ),
                          ),
                          Padding(
                            padding: const EdgeInsets.only(left: 10),
                            child: Icon(
                              Icons.arrow_forward_ios_sharp,
                              size: 12,
                              color: rgba(163, 163, 163, 1),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Divider(
                    height: 1.0,
                    indent: 0.0,
                    color: rgba(242, 242, 242, 1),
                  ),
                  ListTile(
                    onTap: () => {
                      G.pushNamed('/write_group_name', arguments: 'webLink')
                    },
                    contentPadding:
                        EdgeInsets.symmetric(horizontal: 0, vertical: 8),
                    title: Text(
                      "小组网址",
                      style: TextStyle(
                        color: rgba(34, 34, 34, 1),
                      ),
                    ),
                    trailing: SizedBox(
                      width: 130,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          Container(
                            width: 100,
                            child: Text(
                              _formData.myGroup.webLink != null
                                  ? _formData.myGroup.webLink
                                  : '',
                              style: TextStyle(
                                color: rgba(34, 34, 34, 1),
                              ),
                              textAlign: TextAlign.end,
                              overflow: TextOverflow.ellipsis,
                              maxLines: 1,
                            ),
                          ),
                          Padding(
                            padding: const EdgeInsets.only(left: 10),
                            child: Icon(
                              Icons.arrow_forward_ios_sharp,
                              size: 12,
                              color: rgba(163, 163, 163, 1),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Divider(
                    height: 1.0,
                    indent: 0.0,
                    color: rgba(242, 242, 242, 1),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
